home *** CD-ROM | disk | FTP | other *** search
/ Macademic for Students & Teachers / Macademic for Students and Teachers (Quantum Leap)(1992).iso / Fun & Games / CoreWar / Five Musketeers < prev    next >
Encoding:
Text File  |  1985-09-10  |  5.4 KB  |  125 lines  |  [FGHT/CWAR]

  1. *
  2. * The Five Musketeers -- "All for one, and one for all!"
  3. *
  4. * a Core Wars fighter program by Jon Newman
  5. * [75146,210]  B.BADWOLF@LOTSC%ARPA
  6. * PEA '83   Stanford '87
  7. *
  8. * "Freeware" is hardly free when you have to download it
  9. *  across phone lines in another state, but I just had to see
  10. *  the Core Wars manual -- after seeing it, I just had to get
  11. *  the program -- and, finally, after one weekend's intensive
  12. *  hacking, I produced what is in my humble opinion the most
  13. *  sophisticated fighter program around.  Surprisingly, it is
  14. *  a mean fighter too. So:
  15. *
  16. * The Five Musketeers is a unique fighter program based on
  17. *  mutual self-repair by a finite number of co-routines.  The
  18. *  code that follows will replicate into five seperate copies
  19. *  in memory, each 1600 cells apart.  Each "musketeer" has a
  20. *  "big brother" and a "little brother," forming a sort of
  21. *  daisy chain.  Each "little brother" must regularly reassure
  22. *  "big brother" , while "big brother" checks on
  23. *  "little brother" to make sure it has not been subverted or
  24. *  destroyed.  If "little brother" fails to reassure him,
  25. *  "big brother" will copy itself into "little brother"'s
  26. *  location and split off a new process.  If "little brother"
  27. *  is alright, then "big brother" is free to do whatever it
  28. *  chooses.  (Not patronizing, this is the way I think of it
  29. *  myself.)
  30. * "Reassurance" takes place through the location MYTAG.
  31. *  "Big brother" sets it to zero, then waits;  if "little
  32. *  brother" fails to change it to magic number 1373 in time,
  33. *  "big brother" rewrites him.  Since the brothers are not
  34. *  always in sync, "little brother" writes it twice.
  35. *
  36. *
  37. *
  38. @-2
  39. done       mov #1373,mytag       ;reassure big brother
  40.            spl start-3200        ;split off new little brother
  41. *
  42. start      mov #1373,mytag       ; reassure big brother
  43.            cmp #1373,mytag-3200  ; check on little brother
  44.            jmp ok                ; little brother is OK
  45. *
  46. savehim    mov #2,source         ;Oh no, little brother is
  47.            mov #-3199,dest       ;hurt!  Rewrite him!
  48. write      mov @source,@dest
  49.            cmp #-25,source       ;Routine lifted from Gemini,
  50.            jmp done              ;except that it goes
  51.            sub #1,source         ;backwards.
  52.            sub #1,dest
  53.            jmp write
  54. *
  55. ok         mov #0,mytag-3200     ; The optional routine when
  56.            mov #34,timer         ; little brother is OK.
  57. bombloop   mov #0,@target        ; Bombs every point between
  58.            djz reset,timer       ; this musketeer and the one
  59.            sub #1,target         ; above him.  Can be replaced
  60.            jmg bombloop,target   ; with timer loop, vampire
  61.            mov #1571,target      ; attack, anything.
  62.            jmp bombloop          ; See below.
  63. reset      mov #1373,mytag       ;reassure big brother.
  64.            jmp start
  65. *
  66. timer      dat 34                ;# bombs per attack cycle
  67. mytag      dat 1373              ; checked by big brother
  68. source     dat 2                 ;from Gemini: not reset until
  69. dest       dat -3199             ;write cycle begins
  70. target     dat 1571              ; bomb point
  71. *
  72. * Note that each brother checks on the brother 3200 cells
  73. *  below him, not the one 1600 below him.  This improves
  74. *  repair characteristics if two adjoining brothers are lost.
  75. *  They still form a chain, just a more confusing one.
  76. *
  77. * As indicated in the comments, the Musketeers' feeble attack
  78. *  may be replaced with any other code given appropriate
  79. *  changes in the constants.  However, it is essential that
  80. *  the time from START to START remain as long as for the
  81. *  repair cycle (for this version, 144 cycles).  If the attack
  82. *  loop is shorter, a big brother might write to an unhurt
  83. *  little brother itself in the process of writing to a
  84. *  littler brother.  Overlong attack loops increase the delay
  85. *  before loss of little brother is noticed.
  86. * Sometimes, due to strange attacks (e.g. damage to MYTAG),
  87. *  such a rewrite will occur anyway.  The result: two brothers
  88. *  sharing the same space.  This causes strange things to
  89. *  happen, and they multiply like rabbits once set off.  Also,
  90. *  enemies can be subverted to Musketeers -- very weird.  This
  91. *  can be survived though.
  92. *
  93. * Discovery: JMG is just the opposite of JMZ, no cell ever
  94. *  registers as negative no matter what Debug says.  Ugh.
  95. *
  96. *
  97. * A surprise:  in all my testing, The Five Musketeers has never
  98. *  lost a match with any of the seven fighter programs
  99. *  provided in the initial upload.  My results:
  100. *
  101. * Dwarf: two wins.  An excellent display of the self-repairing
  102. *  ability of The Five Musketeers.
  103. * Gemini: two wins.
  104. * Gemini Cannon: three wins, one draw.  When a Gemini lands on
  105. *  a Musketeer, anything can happen.  This is a very wild
  106. *  matchup, try it sometime.
  107. * Imp: two draws.  Imps subvert Musketeers to more Imps, and,
  108. *  as always, are almost unstoppable -- eventually they
  109. *  overwhelm the self-repair process, leaving only Imps.
  110. * Imp Cannon: two draws.
  111. * Vampire: two wins.  Musketeers are very susceptible to Fangs,
  112. *  but the self-repair is so efficient that 500 trash
  113. *  processes still leave it time to replicate into the
  114. *  area already erased.  Raising NPRC in Vampire to 5000
  115. *  will kill the Musketeers.
  116. * Worm: two draws.  Can anything kill a Worm?
  117. *
  118. *
  119. * Well, that's it.  Feel free to try out variations on this
  120. *  very fruitful theme.  The Four Vampires?  The Ten Dwarves?
  121. *  The Two Gemini Cannons (which hopefully keep the Geminis
  122. *  away from the replicating code)?  The mind boggles.
  123. *
  124. *                  Jon Newman
  125.